//
//  ViewController.swift
//  
//
//  Created by joker on 15/7/20.
//
//

import UIKit

class ViewController: UIViewController {

    var selectedItem: String?
    
    lazy var popoverContentController: UINavigationController = {
        let controller = PopoverTableViewController(style: .Plain)
        controller.selectionHandler = self.selectionHandler
        let navigationController = UINavigationController(rootViewController: controller)
        return navigationController
    }()
    lazy var popoverController: UIPopoverController = {
        return UIPopoverController(contentViewController: self.popoverContentController)
    }()

    func selectionHandler(selectedItem: String) {
        self.selectedItem = selectedItem
    }
    @IBAction func displayPopover(sender: UIBarButtonItem) {
        popoverController.presentPopoverFromBarButtonItem(sender, permittedArrowDirections: .Any, animated: true)
    }
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}
